<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
		<meta name="description" content="Everest Admin Panel" />
		<meta name="keywords" content="Admin, Dashboard, Bootstrap3, Sass, transform, CSS3, HTML5, Web design, UI Design, Responsive Dashboard, Responsive Admin, Admin Theme, Best Admin UI, Bootstrap Theme, Wrapbootstrap, Bootstrap" />
		<meta name="author" content="Bootstrap Gallery" />
		<link rel="shortcut icon" href="img/favicon.ico">
		<title>sugonTravle</title>
		
		<!-- Bootstrap CSS -->
		<link href="css/bootstrap.css" rel="stylesheet" media="screen">

		<!-- Animate CSS -->
		<link href="css/animate.css" rel="stylesheet" media="screen">

		<!-- Alertify CSS -->
		<link href="css/alertify/alertify.core.css" rel="stylesheet">
		<link href="css/alertify/alertify.default.css" rel="stylesheet">

		<!-- Main CSS -->
		<link href="css/main.css" rel="stylesheet" media="screen">

		<!-- Font Awesome -->
        <link href="fonts/font-awesome.min.css" rel="stylesheet">
        

		<link href="css/jquery.dataTables.min.css" rel="stylesheet">

		<!-- HTML5 shiv and Respond.js IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
			<script src="js/html5shiv.js"></script>
			<script src="js/respond.min.js"></script>
        <![endif]-->
        
        <style>
            .table>tbody>tr>td{
                text-align:center;
            }
            .table>thead>tr>th{
                text-align:center;
            }
        </style>

	</head>  

	<body>

		<!-- Header Start -->
		<header>

			<!-- Logo starts -->
			<div class="logo">
				<a href="#">
					<img src="img/logo.png" alt="logo">
					<span class="menu-toggle hidden-xs">
						<i class="fa fa-bars"></i>
					</span>
				</a>
			</div>
			<!-- Logo ends -->

			<!-- Custom Search Starts -->
			<div class="custom-search pull-left hidden-xs hidden-sm">
				<input type="text" class="search-query" placeholder="Search here">
				<i class="fa fa-search"></i>
			</div>
			<!-- Custom Search Ends -->

			<!-- Mini right nav starts -->
			<div class="pull-right">
				<ul id="mini-nav" class="clearfix">
					<li class="list-box hidden-lg hidden-md hidden-sm" id="mob-nav">
						<a href="#">
							<i class="fa fa-reorder"></i>
						</a>
					</li>
					<li class="list-box dropdown hidden-xs">
						<a id="drop7" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
							<i class="fa fa-image"></i>
						</a>
						<span class="info-label info-bg animated rubberBand">7+</span>
						<ul class="blog-gallery dropdown-menu fadeInDown animated clearfix recent-tweets">
							<li>
								<img src="img/user1.jpg" alt="User">
							</li>
							<li>
								<img src="img/user2.jpg" alt="User">
							</li>
							<li>
								<img src="img/user3.jpg" alt="User">
							</li>
							<li>
								<img src="img/user4.jpg" alt="User">
							</li>
							<li>
								<img src="img/user5.jpg" alt="User">
							</li>
							<li>
								<img src="img/user6.jpg" alt="User">
							</li>
							<li>
								<img src="img/user7.jpg" alt="User">
							</li>
							<li>
								<img src="img/user8.jpg" alt="User">
							</li>
							<li>
								<img src="img/user9.jpg" alt="User">
							</li>
							<li>
								<img src="img/user3.jpg" alt="User">
							</li>
						</ul>
					</li>
					<li class="list-box dropdown hidden-xs">
						<a id="drop5" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
							<i class="fa fa-th"></i>
						</a>
						<span class="info-label success-bg animated rubberBand">6</span>
						<ul class="dropdown-menu fadeInDown animated quick-actions">
							<li class="plain">Recently Viewed</li>
							<li>
								<a href="profile.html">
									<i class="fa fa-user text-info"></i>
									<p>Users</p>
								</a>
							</li>
							<li>
								<a href="login.html">
									<i class="fa fa-tasks text-warning"></i>
									<p>Tasks</p>
								</a>
							</li>
							<li>
								<a href="typography.html">
									<i class="fa fa-font text-danger"></i>
									<p>Fonts</p>
								</a>
							</li>
							<li>
								<a href="graphs.html">
									<i class="fa fa-globe text-success"></i>
									<p>Graphs</p>
								</a>
							</li>
							<li>
								<a href="graphs.html">
									<i class="fa fa-bank text-danger"></i>
									<p>Home</p>
								</a>
							</li>
							<li>
								<a href="invoice.html">
									<i class="fa fa-file-text text-success"></i>
									<p>Invoice</p>
								</a>
							</li>
						</ul>
					</li>
					<li class="list-box dropdown hidden-xs">
						<a id="drop1" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
							<i class="fa fa-bell"></i>
						</a>
						<span class="info-label danger-bg animated rubberBand">4</span>
						<ul class="dropdown-menu bounceIn animated messages">
							<li class="plain">
								Messages
							</li>
							<li>
								<div class="user-pic">
									<img src="img/user4.jpg" alt="User">
								</div>
								<div class="details">
									<strong class="text-danger">Wilson</strong>
									<span>Uploaded 28 new files yesterday.</span>
								</div>
							</li>
							<li>
								<div class="user-pic">
									<img src="img/user1.jpg" alt="User">
								</div>
								<div class="details">
									<strong class="text-danger">Adams</strong>
									<span>Got 12 new messages.</span>
								</div>
							</li>
							<li>
								<div class="user-pic">
									<img src="img/user3.jpg" alt="User">
								</div>
								<div class="details">
									<strong class="text-info">Sam</strong>
									<span>Uploaded new project files today.</span>
								</div>
							</li>
							<li>
								<div class="user-pic">
									<img src="img/user5.jpg" alt="User">
								</div>
								<div class="details">
									<strong class="text-info">Jennifer</strong>
									<span>128 new purchases last 3 hours.</span>
								</div>
							</li>
						</ul>
					</li>
					<li class="list-box user-profile hidden-xs">
						<a href="login.html" class="user-avtar animated rubberBand">
							<img src="img/user4.jpg" alt="user avatar">
						</a>
					</li>
				</ul>
			</div>
			<!-- Mini right nav ends -->

		</header>
		<!-- Header ends -->

		<!-- Left sidebar starts -->
		<aside id="sidebar">

			<!-- Current User Starts -->
			<div class="current-user">
				<div class="user-avatar animated rubberBand">
					<img src="img/user4.jpg" alt="Current User">
					<span class="busy"></span>
				</div>
				<div class="user-name">Welcome Mr. Lu</div>
				<ul class="user-links">
					<li>
						<a href="profile.html">
							<i class="fa fa-user text-success"></i>
						</a>
					</li>
					<li>
						<a href="invoice.html">
							<i class="fa fa-file-pdf-o text-warning"></i>
						</a>
					</li>
					<li>
						<a href="components.html">
							<i class="fa fa-sliders text-info"></i>
						</a>
					</li>
					<li>
						<a href="login.html">
							<i class="fa fa-sign-out text-danger"></i>
						</a>
					</li>
				</ul>
			</div>
			<!-- Current User Ends -->

			<!-- Menu start -->
			<div id='menu'>
                <ul>
                    <li>
                        <a href='index.html'>
                            <i class="fa fa-desktop"></i>
                            <span>仪表盘</span>
                        </a>
                    </li>
                    <li>
                        <a href='team-members.html'>
                            <i class="fa fa-user"></i> 
                            <span>团员管理</span>
                        </a>
                    </li>
                    <li>
                        <a href='new-group.html'>
                            <i class="fa fa-flask"></i> 
                            <span>新建团队</span>
                        </a>
                    </li>
                    <li>
                        <a href='groups.html'>
                            <i class="fa fa-calendar"></i> 
                            <span>团队管理</span>
                        </a>
                    </li>
                    <li class="highlight">
                        <a href='work-members.html'>
                            <i class="fa fa-github-alt"></i> 
                            <span>员工管理</span>
                            <span class="current-page"></span>
                        </a>
                    </li>
                    <li>
                        <a href='packages.html'>
                            <i class="fa fa-globe"></i> 
                            <span>套餐管理</span>
                        </a>
                    </li>
                    <li>
                        <a href='routes.html'>
                            <i class="fa fa-arrows-h"></i> 
                            <span>路线管理</span>
                        </a>
                    </li>
                    <li>
                        <a href="http://182.61.146.234:8069/web?#action=128&model=tour.route&view_type=list&menu_id=96" target="_Blank" style='text-decoration:none;'>
                            <i class="fa fa-pencil fa-fw"></i>
                            <span>报表助手</span>
                        </a>
                    </li>
                </ul>
            </div>
                <!-- Menu End -->
    
                <div class="modal fade" id="mapInput" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    ×
                                </button>
                                <h4 class="modal-title">
                                    查询城市路线
                                </h4>
                            </div>
                            <div class="modal-body">
                                <form class="form-horizontal" role="form">

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">城市</label>
                                        <div class="col-sm-9" >
                                            <select class="form-control citys" name="city" id="map_city">
                                                <!-- 从后端取到数据 -->
                                                <!-- 如果不选，默认为武汉 -->
                                                <option value="4" id="defaultOption">请选择城市</option>
                                            </select>
                                        </div>
                                    </div>
        
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">
                                    关闭
                                </button>
                                <button type="submit" data-dismiss="modal"  class="btn btn-primary" id="map_city_confirm">
                                    提交
                                </button><span id="tip"> </span>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>
    
                <!-- Freebies Starts -->
                <div class="freebies">
                    
                    <!--Sidebar Extras-->       
                    <div class="sidebar-addons">
                        <ul class="views">
                            <li>
                                <a href='city.html'>
                                    <i class="fa fa-circle-o text-success"></i>
                                    <div class="details">
                                        <p>城市信息</p>
                                    </div>
                                </a>
                                
                                <!--<span class="label label-success">8</span>-->
                            </li>
                            <li>
                                <a href='sights.html'>
                                    <i class="fa fa-circle-o text-info"></i>
                                    <div class="details">
                                        <p>景点信息</p>
                                    </div>
                                </a>
                                <!--<span class="label label-info">7</span>-->
                            </li> 
                            <li>
                                <a href='#' data-toggle="modal" data-target="#mapInput">
                                    <i class="fa fa-circle-o text-danger"></i>
                                    <div class="details">
                                        <p>地图信息</p>
                                    </div>
                                </a>
                                <!--<span class="label label-danger">4</span>-->
                            </li>         
                        </ul>
                    </div>
    
                </div>
			<!-- Freebies Starts -->

		</aside>
		<!-- Left sidebar ends -->

		<!-- Dashboard Wrapper starts -->
		<div class="dashboard-wrapper">

			<!-- Top Bar starts -->
			<div class="top-bar">
				<div class="page-title">
					工作人员信息
				</div>
				<ul class="stats hidden-xs">
					<li>
						<div class="stats-block hidden-sm hidden-xs">
							<span id="downloads_graph"></span>
						</div>
						<div class="stats-details">
							<!--<h4>$<span id="today_income">580</span> <i class="fa fa-chevron-up up"></i></h4>
							<h5>Today's Income</h5>-->
						</div>
					</li>
					<li>
						<div class="stats-block hidden-sm hidden-xs">
							<span id="users_online_graph"></span>
						</div>
						<div class="stats-details">
							<!--<h4>$<span id="today_expenses">235</span> <i class="fa fa-chevron-down down"></i></h4>
							<h5>Today's Expenses</h5>-->
						</div>
					</li>
				</ul>
			</div>
			<!-- Top Bar ends -->

			<!-- Main Container starts -->
			<div class="main-container">

				<!-- Container fluid Starts -->
				<div class="container-fluid">
					
					<!-- Spacer Starts -->
					<div class="spacer">

						<!-- Row start -->
						<div class="row">

                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div class="panel">
                                    <div class="panel-heading">
                                        <div class="panel-title" style="height: 50px;">
                                            <h4 style="float:left;">工作人员</h4>
                                            <div class="btn-group col-lg-3 col-lg-offset-8" role="group" aria-label="...">
                                                <button type="button" class="btn btn-info" data-toggle="modal" data-target="#addUserModal" id="create">新建</button>
                                                <!--<button type="button" class="btn btn-success" data-toggle="modal" data-target="#addUserModal" id="update">更新</button>-->
                                                <button type="button" class="btn btn-success" id="update">更新</button>
                                                <button type="button" class="btn btn-danger" id="delete">删除</button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                        <table id="example" class="cell-border display table" cellspacing="0" width="100%">
                                            <thead>
                                                <tr>
                                                    <th>索引</th>
                                                    <th>工号</th>
                                                    <th>姓名</th>
                                                    <th>性别</th>
                                                    <th>年龄</th>
                                                    <th>证件类型</th>
                                                    <th>证件号</th>
                                                    <th>手机号</th>
                                                    <th>邮箱</th>
                                                    <th>职位</th>
                                                    <th>工龄</th>
                                                </tr>
                                            </thead>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        
						</div>
						<!-- Row end -->

					</div>
					<!-- Spacer Ends -->

				</div>
				<!-- Container fluid ends -->

			</div>
			<!-- Main Container ends -->

			<!-- Right sidebar starts -->
			<div class="right-sidebar">
				
				<!-- Addons starts -->
				<div class="add-on clearfix">
					<div class="add-on-wrapper">
						<h5>Workers</h5>
						<ul class="blog-gallery clearfix">
							<li>
								<img src="img/user1.jpg" alt="User">
							</li>
							<li>
								<img src="img/user2.jpg" alt="User">
							</li>
							<li>
								<img src="img/user3.jpg" alt="User">
							</li>
							<li>
								<img src="img/user4.jpg" alt="User">
							</li>
							<li>
								<img src="img/user5.jpg" alt="User">
							</li>
							<li>
								<img src="img/user6.jpg" alt="User">
							</li>
							<li>
								<img src="img/user7.jpg" alt="User">
							</li>
							<li>
								<img src="img/user8.jpg" alt="User">
							</li>
							<li>
								<img src="img/user3.jpg" alt="User">
							</li>
							<li>
								<img src="img/user9.jpg" alt="User">
							</li>
						</ul>
					</div>
				</div>
				<!-- Addons ends -->

					

			</div>
			<!-- Right sidebar ends -->

			<!-- Footer starts -->
			<footer>
				Copyright Everest Ruiyi 2019.
			</footer>
			<!-- Footer ends -->
			<!-- Footer ends -->

		</div>
		<!-- Dashboard Wrapper ends -->
		
		<!-- 添加弹出表单 -->
		<div class="modal fade" id="addUserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                        </button>
                        <h4 class="modal-title" id="myModalLabel">
                            新建工作人员信息
                        </h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label for="user_id" class="col-sm-3 control-label" >姓名</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="worker_name" value=""
                                           placeholder="姓名" class="col-sm-3 control-label">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="user_name" class="col-sm-3 control-label">性别</label>
                                <div class="col-sm-9">
	                                &nbsp;&nbsp;&nbsp;
								    <input type="radio" name="gender" value="1"/>男
								    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								    <input  type="radio" name="gender" value="0" />女
							    </div>
                            </div>
                            <div class="form-group">
                                <label for="user_age" class="col-sm-3 control-label">年龄</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="user_age" value="" id="age"
                                           placeholder="年龄">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">证件类型</label>
                                <div class="col-sm-9">
                                    <select class="form-control" name="genre" id="type_card">
										<option>居民身份证</option>
										<option>港澳台居民居住证</option>
										<option>护照</option>
									</select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">证件号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="user_major" value="" id="number_card"
                                           placeholder="证件号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">手机号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="user_major" value="" id="telephone"
                                           placeholder="手机号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">邮箱</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="user_major" value="" id="email"
                                           placeholder="邮箱">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">职位</label>
                                <div class="col-sm-9">
                                    <select class="form-control" name="genre" id="position">
										<option>初级导游</option>
										<option>中级导游</option>
										<option>高级导游</option>
									</select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="user_major" class="col-sm-3 control-label">工龄</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="user_major" value="" id="work_age"
                                           placeholder="工龄">
                                </div>
                            </div>
                            
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">
                            关闭
                        </button>
                        <button type="button" class="btn btn-primary" id="submit">
                            提交
                        </button><span id="tip"> </span>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>


		<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
		<script src="js/jquery.js"></script>

		<!-- Include all compiled plugins (below), or include individual files as needed -->
		<script src="js/bootstrap.min.js"></script>

		<!-- Sparkline graphs -->
		<script src="js/sparkline.js"></script>

		<!-- jquery ScrollUp JS -->
        <script src="js/scrollup//jquery.scrollUp.js"></script>
        
        <script src="js/jquery.dataTables.min.js"></script>
        <script src="js/tables.js"></script>

		<!-- Custom Index -->
		<script src="js/custom.js"></script>
        <script type="text/javascript">
        	var worker_name = document.getElementById('worker_name');
        	var gender = document.getElementsByName('gender');
        	var age = document.getElementById('age');
        	var type_card = document.getElementById('type_card');
        	var number_card = document.getElementById('number_card');
        	var telephone = document.getElementById('telephone');
        	var email = document.getElementById('email');
        	var position = document.getElementById('position');
        	var work_age = document.getElementById('work_age');
        	
        	var myModalLabel = document.getElementById('myModalLabel');
        	
        	var submit = document.getElementById('submit');   	
        	var create = document.getElementById('create');
        	var worker = {};
        	
        	// 判断是新建还是修改
        	var flag;

            var citys = $('.citys');
                $.ajax({
                    url: webPath+"city/list",
                    type: "get",
                    success: function(res){
                        result = res.data;
                        for(var i=0; i<result.length; i++){
                            var option = document.createElement('option');
                            option.setAttribute("value",result[i].id);
                            option.innerText = result[i].name;
                            $('.citys').append(option);
                        }

                    },
                    error: function (xhr) {
                        alert(xhr.status);
                    }
                });

            $('#map_city_confirm').click(function(){
                var cityId = $('#map_city').val()
                // console.log('./map.html?cityId=' + cityId);
                window.location.href = './map.html?cityId=' + cityId;
            });
        	
        	create.onclick = function(event){
        		worker_name.value='';
                age.value='';
                number_card.value='';
                telephone.value='';
                email.value='';
                work_age.value='';
                worker.id = null;
                myModalLabel.innerText = '新建工作人员信息';
                flag = 0;
                gender[0].setAttribute('checked','checked');
        	}
        	
        	// 更新
        	var update = document.getElementById('update');
        	update.onclick = function(event){
        		var example = document.getElementById("example");
				var person = example.children[1];
				
				update.setAttribute('data-toggle','modal');
				update.setAttribute('data-target','#addUserModal');
				
				var worker_id;
				myModalLabel.innerText = '修改工作人员信息';
				flag = 1;
				// 用来判断选中了多少条数据
				var record=0;
				for(var i=0; i<person.children.length; i++){
					child = person.children[i];
					if(child.classList.contains("selected")){
						record++;
						worker_id = child.children[1].innerText;
						worker_name.value=child.children[2].innerText;
						if(child.children[3].innerText == '男'){
							gender[1].removeAttribute('checked');
							gender[0].setAttribute('checked','checked');
							
						}else{
							gender[0].removeAttribute('checked');
							gender[1].setAttribute('checked','checked');
						}
                        age.value=child.children[4].innerText;
                        type_card.value = child.children[5].innerText;
//						type_card.value = '护照';
                        number_card.value=child.children[6].innerText;
                        telephone.value=child.children[7].innerText;
                        email.value=child.children[8].innerText;
                        position.value = child.children[9].innerText;
                        work_age.value=child.children[10].innerText;
					}
				}
				
				if(record != 1){
					alert("请选中一条记录！");
					update.removeAttribute('data-toggle');
					update.removeAttribute('data-target');
//					data-toggle="modal" data-target="#addUserModal" 
					return;
					
				}
				
				worker.id = worker_id;
        	}
        	
        	// 删除
        	var delete_button = document.getElementById('delete');
        	delete_button.onclick = function(event){
        		var example = document.getElementById("example");
				var person = example.children[1];
				var worker_id;
				// 用来判断选中了多少条数据
				var record=0;
				for(var i=0; i<person.children.length; i++){
					child = person.children[i];
					if(child.classList.contains("selected")){
						record++;
						worker_id = child.children[1].innerText;
					}
				}
				
				if(record != 1){
					alert("请选中一条记录！"); 
					return;
					
				}else{
					var delete_info = confirm("确定删除吗？");
					if(delete_info == true){
						$.ajax({
		                   url: webPath + "tourworker/delete",
		                   type: "post",
		               		data: "id="+worker_id,
	 	                    success: function(result){
//		                    	location.reload();
								if(result.code == 0) {
                                    table.rows('.selected').remove().draw( false );
                                } else {
                                    alert('删除失败！服务器繁忙')
                                }
		                    },
		                    error: function (xhr) {
		                        alert(xhr.status);
		                    }
		               	});
					}
					
				}
        		
        	}
        	
        	gender[0].onclick = function(event){
        		this.setAttribute('checked','checked');
        		gender[1].removeAttribute('checked');
//      		console.log(this);
        	}
        	gender[1].onclick = function(event){
        		this.setAttribute('checked','checked');
        		gender[0].removeAttribute('checked');
//      		console.log(this);
        	}
        	
        	submit.onclick = function(event){
        		submit.removeAttribute('data-dismiss');
        		// 判断性别
	        	var genderNum;
	        	for(var i=0; i<gender.length; i++){
	        		if(gender[i].getAttribute("checked") == "checked"){
	        			genderNum = gender[i].value;
	        		}
	        	}
//	        	console.log(genderNum);
	        	
	        	worker.name = worker_name.value;
	        	worker.gender = genderNum;
	        	worker.age = age.value;
	        	worker.type_card = type_card.value;
	        	worker.number_card = number_card.value;
	        	worker.telephone = telephone.value;
	        	worker.email = email.value;
	        	worker.position = position.value;
	        	worker.work_age = work_age.value;
//	        	console.log(worker);

				if(worker.name=='' || worker.age == '' || worker.number_card == '' || worker.telephone=='' || worker.email=='' || worker.work_age ==''){
					alert("请填写完整的信息！");
				}else{
					if(flag == 0){
						submit.setAttribute('data-dismiss','modal');
		        		$.ajax({
		                   url: webPath + "tourworker/create",
//							url: "http://127.0.0.1/tourworker/create",
		                   type: "post",
		                   headers: { 
		                        'Content-Type': 'application/json; charset=utf-8'  //multipart/form-data;boundary=--xxxxxxx   application/json
		                   },
		               		data: JSON.stringify(worker),
	 	                    success: function(result){
								if (result.code == 0) {
		                            // 有延迟，但是可以自动刷新
		                            worker.id = result.data;
		                            table.row.add(worker).draw(false);
                               }
		                    },
		                    error: function (xhr) {
		                        alert(xhr.status);
		                    }
	               		});
		        	} else{
		        		submit.setAttribute('data-dismiss','modal');
		        		$.ajax({
		                   url: webPath + "tourworker/update",
//		                   url: "http://127.0.0.1/tourworker/update",
		                   type: "post",
		                   headers: { 
		                        'Content-Type': 'application/json; charset=utf-8'  //multipart/form-data;boundary=--xxxxxxx   application/json
		                   },
		               		data: JSON.stringify(worker),
	  	                    success: function(result){
		                        if (result.code == 0) {
	                                // 有延迟，但是可以自动刷新
	                                table.row('.selected').data(worker).draw(false);
	                            }else{
	                            	alert("发生错误");
	                            }
		                   },
		                   error: function (xhr) {
		                       alert(xhr.status);
		                   }
	               		});
		        	}
				}
    	
       		}
        	
            $(function() {
                $.ajax({
                    url: webPath + 'tourworker/list',
                    type: 'GET',
                    async: false,
                    success(res) {
                        data = res.data;
                    }
                })
                // 表格初始化
                var config = {
                    "ajax": {
                        url: webPath + 'tourworker/list',
                        // 默认为 data 用于指定返回数据对象中的key
                        dataSrc: 'data',
                        // 请求方式
                        type: 'GET'
                    },
                    "columns":[
                        {
                            data: null,
                            width: "40px"
                        },{
                            data: "id",
//                          visible: false
                        },{
                            data: "name"
                        },{
                            data: "gender",
                            render: function(data, type, row, meta) {
                                if (data != 1 && data != 0) {
                                    return "男"
                                }
                                return data == 1? "男":"女";
                            }
                        }, {
                            data: "age"
                        }, {

                            data: "type_card"
                        }, {
                            data: "number_card"
                        }, {
                            data: "telephone"
                        }, {
                            data: "email"
                        }, {
                            data: "position"
                        }, {
                            data: "work_age"
                        }
                    ]
                };
                table = init_table(config);
            })

		</script>
	</body>
</html>